#ifndef WINDOW_H
#define WINDOW_H

#include <QtGui>
#include <vector>
#include <iostream>
#include "output.h"
#include "glwidget.h"
#include "cameraPanel.h"
#include "imageDialog.h"
#include "src/ray.h"

class Window : public QMainWindow{
	Q_OBJECT

	public:
		Window();
		~Window();

    private slots:
        void testRaytracing(Ray);
        void changeRaytracingDepth(int);
        void startRendering();
//        void updateImage(std::vector<double>);
        void newScene();
        void openObjects();
        void openSceneObjects();
        void saveSceneObjects();
        bool saveSceneObjectsAs();
//        void saveSceneImage();

        void changeSelection();

        void editObjectDialog(QTreeWidgetItem *, int);
        void deleteObject();
        void duplicateObject();
        void duplicateObject(QTreeWidgetItem *, Object *);
        Object *duplicateObject(Object *);
        void addPrimitive(Object *);
        void newCuboidPrimitiveDialog();
        void newSpherePrimitiveDialog();
        void newCylinderPrimitiveDialog();
        void newConePrimitiveDialog();

        std::vector<Object*> preOperation(QTreeWidgetItem **);
        void postOperation(QTreeWidgetItem *, Object *);
        void unionOperation();
        void intersectionOperation();
        void differenceOperation();
        void translateOperation();
        void rotateOperation();
        void scaleOperation();

        void updateActions();

    private:
        void createWindow();
        int addTreeItem(Object *, QTreeWidgetItem *, bool);
        int updateObjects(std::vector<Object *>);

        QToolBar *setOperationToolBar;
        QToolBar *geometricOperationToolBar;
        QAction *editObjectAct;
        QAction *deleteObjectAct;
        QAction *duplicateObjectAct;
        QAction *saveObjectsAct;
        QAction *rayTestViewAct;
        QTreeWidget *tree;
        ImageDialog *imageDlg;
        CameraPanel *cameraPanel;

        GLWidget *canvas;
        QList<QTreeWidgetItem *> previousSelected;

        Output output;

        bool inOperation;
};

#endif
